import esriLoader, { loadCss, loadModules } from "esri-loader";
// class InitArcGisJs {
//     static init = async () => {
//         const arcgisBaseUrl = 'http://10.89.6.191:9006/arcgis_js_v416_api/arcgis_js_api/library/4.16/';
//         let moduleJsPath = [
//             `${arcgisBaseUrl}esri/Map.js`,
//             `${arcgisBaseUrl}esri/identity/IdentityManager.js`,
//             `${arcgisBaseUrl}esri/views/SceneView.js`,
//             `${arcgisBaseUrl}esri/geometry/Extent.js`,
//             `${arcgisBaseUrl}esri/geometry/Point.js`,
//             `${arcgisBaseUrl}esri/views/MapView.js`,
//             `${arcgisBaseUrl}esri/Graphic.js`, //graphc
//             `${arcgisBaseUrl}esri/layers/GraphicsLayer.js`,
//             `${arcgisBaseUrl}esri/layers/FeatureLayer.js`,
//             `${arcgisBaseUrl}dojo/_base/lang.js`,
//             `${arcgisBaseUrl}esri/layers/TileLayer.js`,
//         ]
//         let moduleNames = moduleJsPath.map(path => (path.match('[^/]+(?!.*/)')[0]).replace(".js", ""));
//         const arcgisModules = await loadModules(
//             moduleJsPath,
//             {
//                 url: `${arcgisBaseUrl}dojo/dojo.js`,
//                 "Access-Control-Allow-Origin": "*",
//                 "Access-Control-Allow-Credentials": "true",
//                 "Access-Control-Allow-Methods": "*",
//                 "Access-Control-Allow-Headers": "*"
//             }
//         )
//         let modules = {};
//         moduleNames.forEach((key, index) => {
//             modules[key] = arcgisModules[index]
//         });
//         return modules
//     }
// }
// export default InitArcGisJs
// 同步使用
// async created() {
// this.ARCGIS = await InitArcGisJs.init();
// }
class InitArcGisJs {
    static init = async () => {
        let moduleJsPath = [
            "esri/Map",
            "esri/identity/IdentityManager",
            "esri/layers/TileLayer",
            "esri/geometry/Polyline",
            "esri/geometry/Point",
            "esri/geometry/Extent",
            "esri/layers/GraphicsLayer",
            "esri/views/SceneView",
            "esri/layers/ElevationLayer",
            "esri/geometry/Circle",
            "esri/layers/BaseElevationLayer",
            "esri/layers/FeatureLayer",
            "esri/symbols/TextSymbol",
            "esri/symbols/ExtrudeSymbol3DLayer",
            "esri/symbols/SimpleFillSymbol",
            "esri/layers/support/LabelClass",
            "esri/Graphic",
            "esri/Camera",
            "dojo/on",
            "dojo/domReady!"
        ]
        let moduleNames = moduleJsPath.map(path => (path.match('[^/]+(?!.*/)')[0]));
        let options = {
            url: "https://js.arcgis.com/4.20/",
            css: "https://js.arcgis.com/4.20/esri/themes/light/main.css"
        };
        let arcgisModules = await loadModules(moduleJsPath, options);

        let modules = {};
        moduleNames.forEach((key, index) => {
            modules[key] = arcgisModules[index]
        });
        return modules
    }
}
export default InitArcGisJs